﻿<%@ Page Title="" Language="VB" MasterPageFile="~/App/Master/App.master" AutoEventWireup="false" CodeFile="Listen.aspx.vb" Inherits="App_Listen" %>

<%@ Register Src="~/App/Controls/PrivateMessage.ascx" TagPrefix="App" TagName="PrivateMessage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="CphHead" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CphMainContent" runat="Server">


    <!-- box 1 -->
    <div class="row-fluid">
        <!-- console -->
        <asp:UpdatePanel runat="server" ID="UpPConsole" UpdateMode="Conditional" class="listen">
            <ContentTemplate>
                <asp:Button ID="BtnReload_UpPConsole" runat="server" Style="display: none;" Text="Reload" />
                <div class="well-listen">
                    <div class="well-listen-sx">
                        <div class="div-mentions">
                            <div>
                                <asp:LinkButton runat="server" CssClass="bottone-mentions" ID="BtnViewMessage" Text="mentions" />
                            </div>
                            <div>
                                <asp:LinkButton runat="server" CssClass="bottone-message" ID="BtnViewPrivate" Text="private message" />
                            </div>
                        </div>
                        <div class="div-hashtags">
                            <asp:LinkButton runat="server" CssClass="bottone-hashtags" ID="BtnViewHashTagPost" Text="hashtags" />
                        </div>
                        <div class="flag-hashtags">
                            <asp:ListView runat="server" ID="ListHashtag" ClientIDMode="Predictable">
                                <ItemTemplate>
                                    <asp:CheckBox runat="server" ID="ChkHashtag" Checked='<%# Not CBool(Eval("listen_disabled_view"))%>' AutoPostBack="true" OnCheckedChanged="Chk_Click" />
                                    <label for='<%# UI.ListDataItem.GetCheckBox(Container, "ChkHashtag").ClientID%>'>
                                        <span></span>
                                        <%# eval("query") %>
                                    </label>
                                </ItemTemplate>
                            </asp:ListView>
                        </div>
                    </div>

                    <div class="well-listen-dx">
                        <asp:UpdatePanel ID="dsdsdsd" runat="server" UpdateMode="Conditional" RenderMode="Block">
                            <ContentTemplate>
                                <App:PostWrite runat="server" ID="ppp2" />
                            </ContentTemplate>
                        </asp:UpdatePanel>

                    </div>

                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>


    <!-- box 2 -->
    <div class="row-fluid">
        <!-- conversazioni -->
        <asp:UpdatePanel runat="server" ID="UpPMessage" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:Panel runat="server" ID="PnlMessage" CssClass="listen-mentions">
                    <!-- titolo -->
                    <div class="top-bar">
                        mentions
                    <div><a href="#" class="a-icona7-a tooltip" title="Tips Icon"></a></div>
                    </div>
                    <!-- contenuti -->
                    <div class="well-listen-mentions">
                        <asp:ListView runat="server" ID="ListMessage" ClientIDMode="Predictable">

                            <ItemTemplate>
                                <asp:UpdatePanel runat="server" ID="UpPMessageRow" UpdateMode="Conditional">
                                    <ContentTemplate>
                                        <div class="mention" style="background-color: <%# IIf(Me.dic(GloukDB.Alert.Type.MESSAGE).ContainsKey(Eval("post.post_code")), "#f0f7e5", "")%>; padding-left: <%# Eval("post.PostLevel") * 11 + 7 %>px;">
                                            <div class="icona-foto-mention">
                                                <img src="<%# eval("acc")("avatar") %>">
                                            </div>
                                            <div class="content-mention">
                                                <div class="profilo-mention">
                                                    <ul>
                                                        <li class="utente-mention">@<%# Eval("acc")("username")%></li>
                                                        <li class="time-mention"><%# MyUI.Print.TimeNow(Eval("post.pubb_date"))%></li>
                                                        <li class="indietro-mention">
                                                            <%--                                                            <asp:LinkButton runat="server" ID="BtnReply" CssClass="a-icona-indietro" ClientIDMode="AutoID" CommandName="REPLY" />--%>
                                                            <asp:LinkButton runat="server" ID="BtnReply" OnClientClick="Open_PostWrite_Message(this);" CssClass="a-icona-indietro" ClientIDMode="AutoID" CommandName="REPLY" />

                                                        </li>
                                                        <li class="aggiorna-mention">
                                                            <asp:LinkButton runat="server" ID="BtnShare" CssClass="a-icona-aggiorna" ClientIDMode="AutoID" CommandName="SHARE" />
                                                        </li>
                                                        <li class="stella-mention">
                                                            <asp:LinkButton runat="server" ID="BtnFavorite" CssClass="a-icona-stella" ClientIDMode="AutoID" CommandName="ADD_FAVORITE" />
                                                            <%--<a class="a-icona-stella" href="#"></a>--%>
                                                        </li>
                                                        <li class="busta-mention">
                                                            <a class="a-icona9" target="_blank" href="https://twitter.com/<%# Eval("acc")("username")%>/status/<%# Eval("post.post_code")%>"></a>
                                                            <%--<a class="a-icona-busta" href="#"></a>--%>
                                                        </li>
                                                    </ul>
                                                </div>
                                                <div class="testo-mention">
                                                    <%# MyUI.Print.Post(Eval("post.Post_Text"))%>
                                                </div>
                                            </div>
                                            <div class="counter-tweet">
                                                <div class="count">
                                                    <div class="counter-n"><%# UI.Print.Num0(eval("acc")("post_count")) %></div>
                                                    <div class="counter-t">TWEETS</div>
                                                </div>
                                                <div class="count">
                                                    <div class="counter-n"><%# UI.Print.Num0(Eval("acc")("friend_count"))%></div>
                                                    <div class="counter-t">FOLLOWING</div>
                                                </div>
                                                <div class="count">
                                                    <div class="counter-n"><%# UI.Print.Num0(Eval("acc")("follower_count"))%></div>
                                                    <div class="counter-t">FOLLOWERS</div>
                                                </div>
                                            </div>
                                            <div class="ok-dm" align="right">
                                                <%--                                                <div>
                                                    <a class="a-icona9" target="_blank" href="https://twitter.com/<%# Eval("acc")("username")%>/status/<%# Eval("post.post_code")%>"></a>
                                                </div>--%>
                                                <div>
                                                    <asp:LinkButton runat="server" CssClass="a-icona1 tooltip" title="Follow/unfollow this user" ID="BtnFollow" CommandName="FOLLOW" Text="" />
                                                </div>
                                                <div>
                                                    <asp:Label runat="server" ID="LblFollower" CssClass="a-icona2 tooltip" Text="" title="If active, this user is following you"></asp:Label>
                                                </div>
                                                <div>
                                                    <asp:LinkButton runat="server" ID="BtnOpenPrivateMessase" CssClass="a-icona3 tooltip" OnClientClick="Open_Private_Message(this);" CommandName="OPEN_PRIVATE"></asp:LinkButton>
                                                </div>

                                            </div>
                                        </div>

                                        <%--<App:PostWrite runat="server" ID="PostWriteMessage" Visible="false" />--%>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                            </ItemTemplate>

                        </asp:ListView>
                        <App:DataPager runat="server" Controlid="ListMessage" PageSize="20" OnPageChanged="SetListMessage" />

                    </div>
                    <!-- fine contenuti -->
                </asp:Panel>
            </ContentTemplate>
        </asp:UpdatePanel>
        <!-- messaggi privati -->
        <asp:UpdatePanel runat="server" ID="UpPPrivate" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:Panel runat="server" ID="PnlPrivate" CssClass="listen-message">
                    <!-- titolo -->
                    <div class="top-bar">
                        private messages
                        <div><a href="#" class="a-icona7 tooltip" title="Tips Icon"></a></div>
                    </div>
                    <!-- contenuti -->
                    <div class="well-listen-message">
                        <div class="listen-message-head">
                            <div>
                                <asp:LinkButton runat="server" CssClass="bottone-private" ID="Rbt1" Text="all" CommandName="GROUP_PRIVATE" CommandArgument="1" />
                            </div>
                            <div>
                                <asp:LinkButton runat="server" CssClass="bottone-private" ID="Rbt2" Text="sent" CommandName="GROUP_PRIVATE" CommandArgument="2" />
                            </div>
                            <div>
                                <asp:LinkButton runat="server" CssClass="bottone-private" ID="Rbt3" Text="received" CommandName="GROUP_PRIVATE" CommandArgument="3" />
                            </div>
                        </div>
                        <asp:ListView runat="server" ID="ListPrivate" ClientIDMode="Predictable">
                            <ItemTemplate>
                                <asp:UpdatePanel runat="server" ID="UpPPrivateRow" UpdateMode="Conditional">
                                    <ContentTemplate>
                                        <div class="mention" style="background-color: <%# IIf(Me.dic(GloukDB.Alert.Type.PRIVATE_POST ).ContainsKey(Eval("account_code")), "#e9f6fc", "")%>;">

                                            <div class="icona-foto-mention">
                                                <img src="<%# Eval("avatar")%>">
                                            </div>
                                            <div class="content-mention">
                                                <div class="profilo-mention">
                                                    <ul>
                                                        <li class="utente-mention">@<%# Eval("username")%></li>
                                                        <li class="time-mention">(<%# Eval("totmess")%> messages)</li>

                                                    </ul>
                                                </div>
                                            </div>
                                            <div class="counter-tweet">
                                                <div class="count">
                                                    <div class="counter-n"><%# UI.Print.Num0(Eval("post_count"))%></div>
                                                    <div class="counter-t">TWEETS</div>
                                                </div>
                                                <div class="count">
                                                    <div class="counter-n"><%# UI.Print.Num0(Eval("friend_count"))%></div>
                                                    <div class="counter-t">FOLLOWING</div>
                                                </div>
                                                <div class="count">
                                                    <div class="counter-n"><%# UI.Print.Num0(Eval("follower_count"))%></div>
                                                    <div class="counter-t">FOLLOWERS</div>
                                                </div>
                                            </div>
                                            <div class="ok-mess">
                                                <div>
                                                    <asp:LinkButton runat="server" ID="BtnOpenPrivate" CssClass="a-icona3 tooltip" OnClientClick="Open_Private_Message(this);" CommandName="OPEN_PRIVATE"></asp:LinkButton>

                                                </div>
                                                <div>
                                                    <asp:LinkButton runat="server" CssClass="a-icona1 tooltip" title="Follow/unfollow this user" ID="BtnFollowPrivate" CommandName="FOLLOW" Text="" />
                                                </div>
                                                <div>
                                                    <asp:Label runat="server" ID="LblFollowerPrivate" CssClass="a-icona2 tooltip" Text="" title="If active, this user is following you"></asp:Label>

                                                </div>

                                            </div>
                                        </div>
                                        <%--                                        <asp:Panel runat="server" ID="PnlPrivateMess" UpdateMode="Conditional" Visible="false">
                                            <div runat="server" id="div_PrivateMess" style="overflow-y: scroll; width: 100%; height: 300px; overflow-x: hidden;">
                                                <asp:ListView runat="server" ID="ListPrivateMess" ClientIDMode="Predictable">
                                                    <ItemTemplate>

                                                        <asp:Panel runat="server" Visible='<%# Eval("is_sent")%>'>
                                                            <div class="img-message-sent" style="width: 20px;">
                                                                <img src="<%# CurrAccount.Avatar%>">
                                                            </div>
                                                            <div class="message-sent">
                                                                <div class="time-message-sent"><%# MyUI.Print.TimeNow(Eval("pubb_date").value)%></div>
                                                                <div class="testo-message-sent"><%# MyUI.Print.Post (eval("post_text")) %><a class="a-icona-busta-b" href="#"></a></div>
                                                            </div>
                                                        </asp:Panel>
                                                        <asp:Panel runat="server" Visible='<%# Not CBool(Eval("is_sent"))%>'>
                                                            <div class="img-message-receive" style="width: 20px;">
                                                                <img src="<%# Eval("avatar")%>">
                                                            </div>
                                                            <div class="message-receive">
                                                                <div class="time-message-receive"><%# MyUI.Print.TimeNow(Eval("pubb_date").value)%></div>
                                                                <div class="testo-message-receive"><%# MyUI.Print.Post (eval("post_text")) %></div>
                                                            </div>
                                                        </asp:Panel>

                                                    </ItemTemplate>
                                                </asp:ListView>
                                            </div>
                                            <App:PostWrite runat="server" ID="PostPrivate" PrivatePost="True" ToAccount='<%# Eval("username")%>' EnabledMedia="False" />

                                        </asp:Panel>--%>
                                    </ContentTemplate>
                                </asp:UpdatePanel>

                            </ItemTemplate>

                        </asp:ListView>
                        <App:DataPager runat="server" Controlid="ListPrivate" PageSize="25" OnPageChanged="SetListPrivate" />
                    </div>
                </asp:Panel>
            </ContentTemplate>
        </asp:UpdatePanel>
        <!-- post hashtag -->
        <asp:UpdatePanel runat="server" ID="UpPHashTagPost" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:Panel runat="server" ID="PnlHashTagPost" CssClass="listen-hashtag">
                    <!-- titolo -->
                    <div class="top-bar">
                        hashtags
                        <div><a href="#" class="a-icona7 tooltip" title="Tips Icon"></a></div>
                    </div>
                    <!-- contenuti -->
                    <div class="well-listen-hashtag">
                        <asp:ListView runat="server" ID="ListHashtagPost" ClientIDMode="Predictable">
                            <ItemTemplate>
                                <asp:UpdatePanel runat="server" ID="UpPHashtagPostRow" UpdateMode="Conditional">
                                    <ContentTemplate>
                                        <div class="mention">
                                            <div class="content-mention">
                                                <div class="profilo-mention">
                                                    <ul>
                                                        <li class="utente-mention">@<%# Eval("account_username")%></li>
                                                        <li class="time-mention"><%# MyUI.Print.TimeNow2(Eval("pubb_date"))%> ago</li>
                                                        <li class="indietro-mention">
                                                            <asp:LinkButton runat="server" ID="BtnReplyHashTagPost" OnClientClick="Open_PostWrite_Message(this);" CssClass="a-icona-indietro" ClientIDMode="AutoID" CommandName="REPLY" />

                                                            <%--<a class="a-icona-indietro" href="#"></a>--%>

                                                        </li>
                                                        <li class="aggiorna-mention"><a class="a-icona-aggiorna" href="#"></a></li>
                                                        <li class="stella-mention"><a class="a-icona-stella" href="#"></a></li>
                                                        <li class="busta-mention"><a class="a-icona-busta" href="#"></a></li>
                                                    </ul>
                                                </div>
                                                <div class="testo-mention"><%# MyUI.Print.Post(Eval("Post_Text"))%></div>
                                            </div>
                                            <div class="counter-tweet">
                                                <div class="count">
                                                    <div class="counter-n"><%# UI.Print.Num0(Eval("account_follower_count"))%></div>
                                                    <div class="counter-t">FOLLOWERS</div>
                                                </div>
                                            </div>
                                            <div class="ok-dm" align="right">
                                                <div>
                                                    <asp:LinkButton runat="server" CssClass="a-icona1 tooltip" title="Follow/unfollow this user" ID="BtnFollowHashTag" CommandName="FOLLOW" Text="" />
                                                </div>
                                                <div>
                                                    <asp:Label runat="server" ID="LblFollowerHashTag" CssClass="a-icona2 tooltip" Text="" title="If active, this user is following you"></asp:Label>
                                                </div>
                                                <div><a class="a-icona3 tooltip" title="Tips Icon" href="#"></a></div>
                                            </div>
                                            <asp:Panel runat="server" CssClass="listen-foto" Visible='<%# Eval("image_url") <> ""%>'>
                                                <a href="#" target="_blank">
                                                    <img src="<%# Eval("image_url")%>"></a>
                                            </asp:Panel>
                                        </div>
                                    </ContentTemplate>
                                </asp:UpdatePanel>

                            </ItemTemplate>

                        </asp:ListView>
                        <App:DataPager runat="server" Controlid="ListHashtagPost" PageSize="20" OnPageChanged="SetListHashtagPost" />
                    </div>
                </asp:Panel>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>



    <style>
        .ListPrivateMess {
            overflow-y: scroll;
            width: 100%;
            height: 300px;
            overflow-x: hidden;
        }
    </style>

    <script type="text/javascript">

        //var send_post;
        //var private_message;
        $(function () {

            //send_post = $("#send_post");
            //private_message = $("#private_message");

            //$('#close_post').click(function () {
            //    send_post.fadeOut();
            //    return false
            //});

            //$('#close_private').click(function () {
            //    private_message.fadeOut();
            //    return false
            //});


        });

        function RefreshData() {
            //alert('tt');
            //__doPostBack('BtnReload_UpPConsole', '');
            $('#BtnReload_UpPConsole').click();
        }
        function Open_PostWrite_Message(o) {
            Open_Layer({
                layer: send_post,
                attach: function () {
                    //send_post.position({ my: "right top", at: "right bottom+5", of: '#' + o.id });
                    pp = $('#' + o.id).closest(".mention");
                    send_post.position({ my: "left top", at: "left bottom", of: pp });
                    send_post.width(pp.width());
                    //$('#' + o.id).closest(".mention").after(send_post);
                }
            });
        }

        function Open_Private_Message(o) {
            Open_Layer({
                layer: private_message,
                attach: function () {

                    pp = $('#' + o.id).closest(".mention");

                    private_message.position({ my: "left top", at: "left bottom", of: pp });

                    //$('#' + o.id).closest(".mention").after(private_message);
                    ScrollDown($('.ListPrivateMess'));
                }
            });
        }

        function oOpen_PostWrite_Message(o) {

            $('#main_container').append(send_post);

            on_update_panel_server_once(function () {
                //alert($('#' + o.id).parent("#CphMainContent_ListMessage_UpPMessageRow_2"));
                send_post.hide();
                send_post.fadeIn();
                //ff.position({ my: "left top", at: "left bottom", of: '#' + o.id });
                //$("#CphMainContent_ListMessage_UpPMessageRow_2").append(ff);
                $('#' + o.id).closest(".mention").after(send_post);
                //$('#' + o.id).parent().parent().parent().parent().parent().parent().append(ff);

            });
        }

        //function Open_PostWrite_Message(o) {

        //    $('#main_container').append(send_post);

        //    on_update_panel_server_once(function () {
        //        //alert($('#' + o.id).parent("#CphMainContent_ListMessage_UpPMessageRow_2"));
        //        send_post.hide();
        //        send_post.fadeIn();
        //        //ff.position({ my: "left top", at: "left bottom", of: '#' + o.id });
        //        //$("#CphMainContent_ListMessage_UpPMessageRow_2").append(ff);
        //        $('#' + o.id).closest(".mention").after(send_post);
        //        //$('#' + o.id).parent().parent().parent().parent().parent().parent().append(ff);

        //    });
        //}

        //function Open_Private_Message(o) {

        //    $('#main_container').append(private_message);

        //    on_update_panel_server_once(function () {
        //        private_message.hide();
        //        private_message.fadeIn();

        //        $('#' + o.id).closest(".mention").after(private_message);
        //        $('.ListPrivateMess').scrollTop($('.ListPrivateMess')[0].scrollHeight);
        //    });
        //}

    </script>

</asp:Content>
